package org.phpgwt.tester.client.classes;

import java.util.Date;

import org.phpgwt.annotations.DateFormat;
import org.phpgwt.annotations.PublicFields;
import org.phpgwt.remote.PHPObject;

@PublicFields
public class TestObject1 implements PHPObject {
	private byte byteVal;
	private short shortVal;
	private int intVal;
	private long longVal;
	private float floatVal;
	private double doubleVal;
	private char charVal;
	private String stringVal;
	private boolean booleanVal;
	@DateFormat("yyyy-MM-dd")
	private Date dateVal;
	private TestObject1 testObject1;

	public byte getByteVal() {
		return byteVal;
	}

	public void setByteVal(byte byteVal) {
		this.byteVal = byteVal;
	}

	public short getShortVal() {
		return shortVal;
	}

	public void setShortVal(short shortVal) {
		this.shortVal = shortVal;
	}

	public int getIntVal() {
		return intVal;
	}

	public void setIntVal(int intVal) {
		this.intVal = intVal;
	}

	public long getLongVal() {
		return longVal;
	}

	public void setLongVal(long longVal) {
		this.longVal = longVal;
	}

	public float getFloatVal() {
		return floatVal;
	}

	public void setFloatVal(float floatVal) {
		this.floatVal = floatVal;
	}

	public double getDoubleVal() {
		return doubleVal;
	}

	public void setDoubleVal(double doubleVal) {
		this.doubleVal = doubleVal;
	}

	public char getCharVal() {
		return charVal;
	}

	public void setCharVal(char charVal) {
		this.charVal = charVal;
	}

	public String getStringVal() {
		return stringVal;
	}

	public void setStringVal(String stringVal) {
		this.stringVal = stringVal;
	}

	public boolean isBooleanVal() {
		return booleanVal;
	}

	public void setBooleanVal(boolean booleanVal) {
		this.booleanVal = booleanVal;
	}

	public Date getDateVal() {
		return dateVal;
	}

	public void setDateVal(Date dateVal) {
		this.dateVal = dateVal;
	}

	public TestObject1 getTestObject1() {
		return testObject1;
	}

	public void setTestObject1(TestObject1 testObject1) {
		this.testObject1 = testObject1;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj.getClass() != TestObject1.class) {
			return false;
		} else {
			TestObject1 other = (TestObject1) obj;

			if (byteVal == other.getByteVal() && shortVal == other.getShortVal() && intVal == other.getIntVal()
					&& longVal == other.getLongVal() && floatVal == other.getFloatVal() && doubleVal == other.getDoubleVal()
					&& charVal == other.getCharVal() && booleanVal == other.isBooleanVal()) {
				if ((stringVal != null && !stringVal.equals(other.getStringVal())) || (stringVal == null && other.getStringVal() != null)
						|| (testObject1 != null && !testObject1.equals(other.getTestObject1()))
						|| (testObject1 == null && other.getTestObject1() != null)) {
					return false;
				} else {
					return true;
				}
			} else {
				return false;
			}
		}
	}
}
